<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="{{ asset('index/static/css/main.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ asset('index/layui/css/layui.css') }}">
    <script type="text/javascript" src="{{ asset('index/layui/layui.js') }} "></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<body>
<link rel="stylesheet" href="{{asset('css/app.css')}}">



<div class="header">
    <div class="headerLayout w1200">
        <div class="headerCon">
            <h1 class="mallLogo">
                <a href="#" title="母婴商城">
                    <img src="/index/static/img/logo.png">
                </a>
            </h1>
            <div class="mallSearch">
                <form action="" class="layui-form" novalidate>
                    <input type="text" name="title" required  lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入需要的商品">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">
                        <i class="layui-icon layui-icon-search"></i>
                    </button>
                    <input type="hidden" name="" value="">
                </form>
            </div>
        </div>
    </div>
</div>


<div class="content content-nav-base commodity-content">
    <div class="main-nav">
        <div class="inner-cont0">
            <div class="inner-cont1 w1200">
                <div class="inner-cont2">
                    <a href="/goods/lists" class="active">所有商品</a>
                    <a href="buytoday.html">今日团购</a>
                    <a href="information.html">母婴资讯</a>
                    <a href="about.html">关于我们</a>
                </div>
            </div>
        </div>
    </div>
    <div class="commod-cont-wrap">
        <div class="commod-cont w1200 layui-clear">
            <div class="left-nav">
                <div class="title">所有分类</div>
                <div class="list-box">
                    @foreach ($categorys as $category)
                    <dl>
                        <dt>{{$category['name']}}</dt>
                        @isset($category['children'])
                            @foreach ($category['children'] as $children)
                        <dd><a href="/goods/lists/{{$children['id']}}">{{$children['name']}}</a></dd>
                            @endforeach
                        @endisset
                    </dl>
                    @endforeach
                </div>
            </div>
            <div class="right-cont-wrap">
                <div class="right-cont">
                    <div class="cont-list layui-clear" id="list-cont">
                        @foreach ($goods as $good)
                        <div class="item">
                            <div class="img">
                                {{--<a href="javascript:;"><img src="/index/static/img/paging_img1.jpg"></a>--}}
                                <a href="/goods/details/{{$good['sku_id']}}"><img style="width: 280px;height: 280px" src="/{{$good['main_image']}}"></a>
                            </div>
                            <div class="text">
                                <p class="title">{{$good['name']}}</p>
                                <p class="price">
                                    <span class="pri">￥{{$good['price']}}</span>
                                    <span class="nub">{{$good['stock']}}库存</span>
                                </p>
                            </div>
                        </div>
                        @endforeach

                    </div>
                    <div class="pull-right paginate">
                        {{ $goods->links() }}
                    </div>
                    {{--<div id="demo0" style="text-align: center;"></div>--}}
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    layui.config({
        base: '/index/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
    }).use(['mm','laypage','jquery'],function(){
        var laypage = layui.laypage,$ = layui.$,
            mm = layui.mm;
        laypage.render({
            elem: 'demo0'
            ,count: 100 //数据总数
        });


        // 模版引擎导入
        //  var html = demo.innerHTML;
        //  var listCont = document.getElementById('list-cont');
        //  // console.log(layui.router("#/about.html"))
        // mm.request({
        //     url: '../json/commodity.json',
        //     success : function(res){
        //       console.log(res)
        //       listCont.innerHTML = mm.renderHtml(html,res)
        //     },
        //     error: function(res){
        //       console.log(res);
        //     }
        //   })

        $('.sort a').on('click',function(){
            $(this).addClass('active').siblings().removeClass('active');
        })
        $('.list-box dt').on('click',function(){
            if($(this).attr('off')){
                $(this).removeClass('active').siblings('dd').show()
                $(this).attr('off','')
            }else{
                $(this).addClass('active').siblings('dd').hide()
                $(this).attr('off',true)
            }
        })

    });
</script>


</body>
</html>